<?php
session_name(DicomScience);
session_start();


/*
 * The writeBlog.php Controller listens on http_get option author and message id. If the author corresponds to the 
 * author of the message specified by it's message id, the blogentry will be deleted.
 */ 
 
// Getting global settings
require_once('../includes/gset.php');

// Defining response language
$session_language = $_SESSION['lang'];
if ($session_language == "") {
	
	// Assuming Controller has not been triggered by a PHP Session
	if ($lang == 1)	{

		require_once ('../includes/language/german.php');	
			
	} elseif($lang == 2){

		require_once ('../includes/language/english.php');
	
	} elseif($lang == 3){

		require_once ('../includes/language/french.php');
	
	}	
	
}

$delUsrId = $_GET['userid'];
$delBlogId = $_GET['blogid'];

require('../includes/database/connect.php');

$sql_checkUserid = "SELECT id_blog, id_staff from blog WHERE id_blog = '$delBlogId'";
$checkUserid = mysql_query($sql_checkUserid);

while($id = mysql_fetch_object($checkUserid)){
	
	$usrid = $id->id_staff;
	
}

if ($usrid==$delUsrId){
	
	$sql_deleteBlog = "DELETE FROM blog WHERE id_blog = $delBlogId";
	$deleteBlog = mysql_query($sql_deleteBlog);
	
	header("Content-type: text/xml"); 
	echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>";
	echo "<newBlog>";
		echo "<status>";
		echo "success";
		echo "</status>";
	echo "</newBlog>";
		
} else{
	
	header("Content-type: text/xml"); 	
	echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>";
	echo "<newBlogStatus>";
		echo "<status>";
		echo "error";
		echo "</status>";
	echo "</newBlogStatus>";
	
}

require('../includes/database/closedb.php');

?>